package com.example.restful01.controller;

import com.example.restful01.model.BorrowRecords;
import com.example.restful01.service.ReportsService;
import com.example.restful01.service.ReservationService;
import com.example.restful01.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api") // 与前端axios的baseURL对应
@CrossOrigin // 跨域注解，也可以使用上面的全局配置
public class ReportsController {

    @Autowired
    private ReportsService reportsService;

    // 举报列表接口
    @GetMapping("/initreportlist")
    public Result initreportlist() {
            return Result.success(reportsService.list());
    }

    //举报删除接口
    @DeleteMapping("/auditcomment")
    public Result auditComment(@RequestParam Integer id) {
        if (reportsService.removeById(id)){
            return Result.success("删除举报成功！");
        }
        else return Result.error("删除举报失败！");
    }

    @GetMapping("/initstureport")
    public Result initStuReport(@RequestParam Integer reporterId) {
            return Result.success(reportsService.initStuReport(reporterId));

        }
    }
